package org.dromara.system.controller.api;

import lombok.RequiredArgsConstructor;
import org.dromara.common.core.domain.R;
import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.common.web.core.BaseController;
import org.dromara.system.domain.bo.XcxUserUpdateReq;
import org.dromara.system.domain.vo.ServiceContentVo;
import org.dromara.system.domain.vo.WechatServiceContentVo;
import org.dromara.system.domain.vo.XcxUserVo;
import org.dromara.system.service.IXcxUserService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 小程序用户API
 *
 * @author maoningchuan
 * @date 2025-09-03
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/api/XcxUser")
public class FrontXcxUserController extends BaseController {

    private final IXcxUserService xcxUserService;


    /**
     * 获取用户信息
     */
    @GetMapping("/getInfo")
    public R<XcxUserVo> getInfo() {
        Long xcxUserId = LoginHelper.getLoginUser().getUserId();
        XcxUserVo xcxUserVo = xcxUserService.getXcxUserInfo(xcxUserId);
        return R.ok(xcxUserVo);
    }


    /**
     * 更新用户信息
     */
    @PostMapping("/updateProfile")
    public R<Void> updateProfile(@RequestBody XcxUserUpdateReq bo) {
        Long xcxUserId = LoginHelper.getLoginUser().getUserId();
        xcxUserService.updateProfile(bo, xcxUserId);
        return R.ok();
    }


    /**
     *
     */
    @GetMapping("/getAvailableServiceContent")
    public R<List<WechatServiceContentVo>> getAvailableServiceContent() {
        Long xcxUserId = LoginHelper.getLoginUser().getUserId();
        List<WechatServiceContentVo> serviceContentList = xcxUserService.getAvailableServiceContent(xcxUserId);
        return R.ok(serviceContentList);
    }


}
